home *** CD-ROM | disk | FTP | other *** search
/ Ahoy 1988 October / Ahoy_Magazine_88-10_1988_Double_L.d64 / Factor Fun 2 (.txt) < prev    next >
Commodore BASIC  |  2022-10-26  |  627b  |  22 lines

  1. 0 print"[147]":poke53280,6:poke53281,0
  2. 1 rem ==================================
  3. 2 rem    commodares problem #52-4 :
  4. 3 rem       factor fun
  5. 4 rem    solution by
  6. 5 rem       claude landusky
  7. 6 rem ==================================
  8. 10 ti$="000000":print"initialization takes over an hour for n to reach 31627...":print:print"n ="
  9. 20 dim p(3500):p(0)=2:c=1
  10. 30 forn=3to31627step2:x=0:print n;
  11. 40 q=p(x):ifq*q>nthenp(c)=n:c=c+1:goto70
  12. 50 ifn/q=int(n/q)then70
  13. 60 x=x+1:goto40
  14. 70 next:print ti$
  15. 80 input"number to factor";n:ti$="000000":f=0:c=0:ifn>999999999then80
  16. 90 q=p(f):ifq*q>nthen120
  17. 100 ifn/q=int(n/q)thenn=n/q:c=1:printq;:goto100
  18. 110 f=f+1:goto90
  19. 120 ifc=0thenprint"prime"=;:goto140
  20. 130 ifn<>1thenprintn;
  21. 140 print:printti$:goto80
  22.